﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using System.Data;
using System.Data.SqlClient;
using System.Text;

namespace tp
{
    public partial class muguanli : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            
                if (Session["Userguanli"] == null)
                {
                    Response.Redirect("index.aspx");
                }
                else
                {
                    string str;
                    str = (string)Session["Userguanli"];
                    this.Userguanli.Text = "当前用户：" + Session["Userguanli"].ToString();
                    //string strpassword;
                    //strpassword = (string)Session["Userpassword"];
                }
            }

        

        protected void ibsee_Click(object sender, ImageClickEventArgs e)
        {
            if (Session["Userguanli"] != null)
            {
                string strno;
                strno = (string)Session["Userguanli"];
                string str = "Data Source=pc.hstc.cn;Initial Catalog=dhd2014112142;User ID=2014112142;Password=19961124";
                SqlConnection conn = new SqlConnection(str);
                try
                {
                    conn.Open();
                    string sql = "SELECT  No,Name,College,Birth,Iden,Addr,Age  FROM Infomation  WHERE(Name =N'" + strno + "')";
                    SqlCommand cmd = new SqlCommand(sql, conn);
                    SqlDataReader dr = cmd.ExecuteReader();//ExecuteReader是一个对象，需要重新定义对象
                    if (dr.Read())
                    {

                        this.txtno.Text = dr["No"].ToString();
                        this.txtname.Text = dr["Name"].ToString();
                        this.txtcoll.Text = dr["College"].ToString();
                        this.txtbirth.Text = dr["Birth"].ToString();
                        this.txtiden.Text = dr["Iden"].ToString();
                        this.txtaddr.Text = dr["Addr"].ToString();
                        this.txtage.Text = dr["Age"].ToString();
                    }
                }
                catch (Exception ex)
                {
                    this.lbl.Text = ex.Message;
                }
                finally
                {
                    conn.Close();
                }
            }
        }
        protected void ibfabu_Click(object sender, ImageClickEventArgs e)
        {
            Response.Write("<script>alert('没有修改,请再次确认!'); location.href = '/finally.aspx';</script>");
        }
        protected void ibxiugai_Click(object sender, ImageClickEventArgs e)
        {
            Response.Write("<script>alert('请修改信息!'); location.href = '/xiugai.aspx';</script>");
        }

        protected void Page_PreInit(object sender, EventArgs e)
        {
            if (Request.QueryString["Theme"] != null)
                Page.Theme = Request.QueryString["Theme"].ToString();

        }
        protected void ibhuanfu_Click(object sender, ImageClickEventArgs e)
        {
            Response.Redirect("muguanli.aspx?Theme=" + ddlhuanfu.SelectedValue + "");
        }

        protected void ddlhuanfu_SelectedIndexChanged(object sender, EventArgs e)
        {

        }

        }
    }